package com.cisetech.web.bobocai.houtai;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cisetech.service.PasswordService;
import com.cisetech.util.session.SystemRequestContext;
import com.cisetech.vo.bobocai.LUser;

//密碼控制器
@Controller
@RequestMapping(value="/ht/password")
public class PasswordController {
	@Autowired
	PasswordService passwordService;
	
	@RequestMapping(value="",method=RequestMethod.GET)
	public String index(Model model,HttpServletResponse response,HttpServletRequest request){
		LUser user = SystemRequestContext.getUser();
		if (user!=null) {
			model.addAttribute("user", user);
			model.addAttribute("superadmin", user.getSuperadmin());
		}
		return "houtai/pass";
	}
	
	//修改密码
	@ResponseBody
	@RequestMapping(value="/update",method=RequestMethod.POST)
	public String updatePass(LUser user,HttpServletResponse response,HttpServletRequest request){
		String newpassword = request.getParameter("newpassword");
		String newpasswords = request.getParameter("newpasswords");
		String s = passwordService.updatePass(user, newpassword, newpasswords, request);
		return s;
	}
	
	
}
